﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="SeaduseSate", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(SeaduseSate))]
    public class SeaduseSateSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ISeaduseSate clazz;
        
        public SeaduseSateSerializer(ISeaduseSate clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Paragrahv!=null) {
                Writer.WriteStartElement("Paragrahv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Paragrahv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ParagrahvPrimm!=null) {
                Writer.WriteStartElement("ParagrahvPrimm");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ParagrahvPrimm))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Punkt!=null) {
                Writer.WriteStartElement("Punkt");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Punkt))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PunktPrimm!=null) {
                Writer.WriteStartElement("PunktPrimm");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PunktPrimm))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tekst!=null) {
                Writer.WriteStartElement("Tekst");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tekst))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.SeadustikKL!=null) {
                Writer.WriteStartElement("SeadustikKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.SeadustikKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LiikKL!=null) {
                Writer.WriteStartElement("LiikKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.LiikKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Loige!=null) {
                Writer.WriteStartElement("Loige");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Loige))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoigePrimm!=null) {
                Writer.WriteStartElement("LoigePrimm");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.LoigePrimm))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TekstLyhendatult!=null) {
                Writer.WriteStartElement("TekstLyhendatult");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TekstLyhendatult))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ObjektID!=null) {
                Writer.WriteStartElement("ObjektID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.ObjektID))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKP!=null) {
                Writer.WriteStartElement("AlgusKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.AlgusKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKP!=null) {
                Writer.WriteStartElement("LoppKP");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.LoppKP))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PeatykkNR!=null) {
                Writer.WriteStartElement("PeatykkNR");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PeatykkNR))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PeatykiNimetusKL!=null) {
                Writer.WriteStartElement("PeatykiNimetusKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.PeatykiNimetusKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.JaguNR!=null) {
                Writer.WriteStartElement("JaguNR");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.JaguNR))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.JaoNimetusKL!=null) {
                Writer.WriteStartElement("JaoNimetusKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.JaoNimetusKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.JaotisNR!=null) {
                Writer.WriteStartElement("JaotisNR");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.JaotisNR))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.JaotiseNimetusKL!=null) {
                Writer.WriteStartElement("JaotiseNimetusKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.JaotiseNimetusKL))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Paragrahv") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Paragrahv = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Paragrahv")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ParagrahvPrimm") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.ParagrahvPrimm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ParagrahvPrimm")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Punkt") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Punkt = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Punkt")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="PunktPrimm") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.PunktPrimm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("PunktPrimm")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Tekst") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Tekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Tekst")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="SeadustikKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.SeadustikKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("SeadustikKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="LiikKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.LiikKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("LiikKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Loige") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Loige = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Loige")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="LoigePrimm") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.LoigePrimm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("LoigePrimm")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="TekstLyhendatult") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TekstLyhendatult = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("TekstLyhendatult")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ObjektID") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>SeaduseSate>ObjektID");
                }
                clazz.ObjektID = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("ObjektID")).Value;
            }
            if (Reader.LocalName=="AlgusKP") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AlgusKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("AlgusKP")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="LoppKP") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.LoppKP = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("LoppKP")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="PeatykkNR") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.PeatykkNR = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("PeatykkNR")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="PeatykiNimetusKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.PeatykiNimetusKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("PeatykiNimetusKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="JaguNR") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.JaguNR = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("JaguNR")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="JaoNimetusKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.JaoNimetusKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("JaoNimetusKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="JaotisNR") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.JaotisNR = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("JaotisNR")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="JaotiseNimetusKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.JaotiseNimetusKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("JaotiseNimetusKL")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
